<!--
 * @Author: wenhui wenhui@wenhuiweb.cn
 * @Date: 2024-08-26
 * @Description:
-->
<template>
  <div class="ship-page-container" v-loading="loading">
    <el-form :model="form" label-width="160px" label-position="left" label-suffix="：">
      <el-form-item label="物流查询key">
        <div>
          <el-input v-model="form.ship" placeholder="物流查询key"></el-input>
          <small class="text-gray-500 flex mt-1">用于查询物流信息，接口申请（仅供参考）</small>
        </div>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" size="default" @click="handleOk">保存</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';

import { getSysConfig, setSysConfig } from '@/api/setting';
import { toast } from '@/utils/common';

const form = reactive({
  ship: ''
})

const loading = ref(false);
const initLoadData = async () => {
  loading.value = true;
  const res = await getSysConfig({})
    .finally(() => loading.value = false);
  for (const k in form) {
    form[k] = res[k];
  }
}

const handleOk = () => {
  loading.value = true
  setSysConfig({ ...form })
    .then(() => initLoadData())
    .finally(() => loading.value = false);
  toast("修改成功");
};

// 挂载获取
onMounted(() => initLoadData());
</script>

<style lang="less" scoped>
.ship-page-container {
  @apply flex-1 flex flex-col p-5 rounded bg-white;
  max-height: 100%;
}
</style>